package com.niuxiaofa.newlaw.adapter;

import android.graphics.Color;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.niuxiaofa.newlaw.Bean.SignInBean;
import com.niuxiaofa.newlaw.R;
import com.niuxiaofa.newlaw.Tools.UIUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import www.linwg.org.lib.LCardView;


public class SignInAdapter extends RecyclerView.Adapter<SignInAdapter.ViewHolder> {
    public List<SignInBean> listEntities;
    Onclick onclick;


    public SignInAdapter(List<SignInBean> newsList, Onclick onclick) {
        this.onclick = onclick;
        this.listEntities = newsList;
    }


    @Override
    public ViewHolder onCreateViewHolder( ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_sign, viewGroup, false);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder( ViewHolder viewHolder, int i) {

        SignInBean listEntity = listEntities.get(i);


        switch (listEntity.getType()){
            case 0:
                viewHolder.lcard.setCardBackgroundColor(Color.parseColor("#FFF7F7F7"));
                viewHolder.no.setTextColor(Color.parseColor("#FF999999"));
                viewHolder.bg_image.setImageBitmap(UIUtils.getBitmap(R.mipmap.no_sign));
                break;
            case 1:
                viewHolder.lcard.setCardBackgroundColor(Color.parseColor("#FFFEF3D3"));
                viewHolder.no.setTextColor(Color.parseColor("#FFF86E25"));
                viewHolder.bg_image.setImageBitmap(UIUtils.getBitmap(R.mipmap.yes));
                break;

            case 2:
                viewHolder.lcard.setCardBackgroundColor(Color.parseColor("#FFF7F7F7"));
                viewHolder.no.setTextColor(Color.parseColor("#FF999999"));
                viewHolder.bg_image.setImageBitmap(UIUtils.getBitmap(R.mipmap.examination));
                break;

        }

        viewHolder.day.setText(listEntity.getDate());

        viewHolder.no.setText("-"+i+"-");

    }

    @Override
    public int getItemCount() {
        return listEntities.size();
    }

    public interface Onclick {

        void onclick(int c);

    }

    static class ViewHolder extends RecyclerView.ViewHolder {


        @BindView(R.id.day)
        TextView day;

        @BindView(R.id.lcard)
        LCardView lcard;

        @BindView(R.id.bg_image)
        ImageView bg_image;

        @BindView(R.id.no)
        TextView no;

        public ViewHolder( View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
